package com.freak.wanandroid.model.frequently;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.freak.httpmanager.BaseViewModel;
import com.freak.httpmanager.callback.ApiCallback;
import com.freak.httpmanager.callback.SubscriberCallBack;
import com.freak.wanandroid.bean.FrequentlyBean;

import java.util.List;

/**
 * Created by 74099 on 2018/9/6.
 */

public class FrequentlyViewModel extends BaseViewModel<FrequentlyRepository> {
    protected MutableLiveData<List<FrequentlyBean>> mGetFrequently = new MutableLiveData<>();
    protected MutableLiveData<String> mGetFrequentlyError = new MutableLiveData<>();

    public FrequentlyViewModel(@NonNull Application application) {
        super(application);
    }

    public void getFrequently() {
        mRepository.getFrequently(new SubscriberCallBack<>(new ApiCallback<List<FrequentlyBean>>() {
            @Override
            public void onSuccess(List<FrequentlyBean> model) {
                mGetFrequently.postValue(model);
            }

            @Override
            public void onFailure(String msg) {
                mGetFrequentlyError.postValue(msg);
            }
        }));
    }
}
